﻿using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Activities.Validation;
using WFExtended.Activities;
using System.Activities;
using System.Activities.Statements;
using Microsoft.Activities.UnitTesting;

namespace WFExtended.Tests.Activities
{

    [TestClass]
    public class GetWorkflowIDTest
    {
        
        public GetWorkflowIDTest()
        {

        }

        [TestMethod]
        public void GetWorkflowIDWithoutWorkflowIDValidationTest()
        {
            ValidationResults result = ActivityValidationServices.Validate(new GetWorkflowID());

            Assert.AreEqual(0, result.Errors.Count);
            Assert.AreEqual(0, result.Warnings.Count);
        }

        [TestMethod]
        public void GetWorkflowIDWithWorkflowIDValidationTest()
        {
            Variable<Guid> workflowID = new Variable<Guid>();

            Activity workflow = new Sequence()
            {
                Variables =
                {
                    workflowID
                },
                Activities =
                {
                    new GetWorkflowID()
                    {
                        WorkflowID = workflowID
                    }
                }
            };

            ValidationResults result = ActivityValidationServices.Validate(workflow);

            Assert.AreEqual(0, result.Errors.Count);
            Assert.AreEqual(0, result.Warnings.Count);
        }

        [TestMethod]
        public void GetWorkflowIDExecutionTest()
        {
            var host = WorkflowInvokerTest.Create(new GetWorkflowID());
            host.TestActivity();

            Assert.AreEqual(0, host.InArguments.Count);
            Assert.AreEqual(1, host.Output.Count);
            Assert.AreNotEqual(Guid.Empty, host.OutArguments.WorkflowID);

        }

    }
}
